import flet as ft


def validate_input(value):
    # 只允许输入字母和数字的正则表达式
    return value.isalnum()


def register(page: ft.Page):
    page.title = "登录"
    # page.vertical_alignment = ft.VerticalAlignment.START
    # page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
    page.add(
        ft.Container(
            content=ft.Card(
                ft.Column(
                    [
                        ft.Container(
                            content=ft.Row(
                                [ft.Column([
                                    ft.Text("邮箱"), ft.Text("密码"), ft.Text("验证码")], spacing=40
                                ), ft.Column([
                                    ft.TextField(input_filter= ft.InputFilter(allow=True, regex_string=r'^[a-zA-Z0-9]*$', replacement_string="")),
                                    ft.TextField(input_filter= ft.InputFilter(allow=True, regex_string=r'^[a-zA-Z0-9]*$', replacement_string="")),
                                    ft.TextField(input_filter= ft.InputFilter(allow=True, regex_string=r'^[a-zA-Z0-9]*$', replacement_string=""))]
                                )],
                                alignment=ft.MainAxisAlignment.CENTER)
                        ),
                        ft.Container(content=ft.TextButton("注册"), alignment=ft.Alignment(0, 0))
                    ], alignment=ft.MainAxisAlignment.CENTER
                ),
                width=500, height=300,
            ), alignment=ft.Alignment(0, 0),  # 设置容器内部内容的对齐方式
            width=page.width, height=page.height  # 使容器覆盖整个页面
        )
    )


if __name__ == '__main__':
    ft.app(target=register)
    # main_yl()
    pass
